<?php

namespace api\modules\v1\controllers\task;

use api\controllers\OnAuthController;
use common\enums\StatusEnum;
use common\helpers\ResultHelper;
use common\models\member\Level;
use Yii;
use yii\data\ActiveDataProvider;
use yii\web\NotFoundHttpException;

/**
 * 默认控制器
 *
 * Class IndexController
 * @package api\modules\v1\controllers
 * @property \yii\db\ActiveRecord $modelClass
 * @author  
 */
class LevelController extends OnAuthController
{
    public $modelClass = Level::class;

    /**
     * 不用进行登录验证的方法
     * 例如： ['index', 'update', 'create', 'view', 'delete']
     * 默认全部需要验证
     *
     * @var array
     */
    protected $authOptional = ['index'];

    /**
     * @return string|\yii\data\ActiveDataProvider
     */

    public function actionIndex()
    {
        return new ActiveDataProvider([
            'query' => $this->modelClass::find()
                ->where(['status' => StatusEnum::ENABLED])
                ->andFilterWhere(['merchant_id' => $this->getMerchantId()])
                ->select('id,level,name,money,detail,daily_tasks,daily_profit,pre_order,monthly_inconme')
                ->orderBy('id desc')
                ->asArray(),
            'pagination' => [
                'pageSize' => $this->pageSize,
                'validatePage' => false, // 超出分页不返回data
            ],
        ]);
    }

    public function actionBuy()
    {
        $id = Yii::$app->request->post('id');
        
    }
}
